package cn.tedu.charging.device.controller;

import cn.tedu.charging.common.pojo.JsonResult;
import cn.tedu.charging.common.pojo.Param.GunStatusUpdateParam;
import cn.tedu.charging.common.pojo.VO.StationInfoVO;
import cn.tedu.charging.device.service.DeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@Api(tags = "场站模块")
@RestController
@RequestMapping("device")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;
    @ApiOperation(value = "获取场站信息")
    @GetMapping("/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable Integer gunId)
    {
        log.debug("获取枪信息-入参:{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfoVO(gunId);
        log.debug("获取场站信息-入参{}，出参:{}",gunId,stationInfoVO);
        JsonResult<StationInfoVO> result = JsonResult.ok(stationInfoVO,"获取用户信息成功");
        log.debug("获取场站信息-入参{}，出参:{}",gunId,result);
        return result;
    }
    @ApiOperation(value = "更新枪状态")
    @PostMapping("/station/gun/status/update")
    public JsonResult<Boolean> updateGunInfo(@RequestBody GunStatusUpdateParam gunStatusUpdateParam)
    {
        log.debug("获取枪信息-入参:{}",gunStatusUpdateParam);
        Boolean success= deviceService.updateGunStatus(gunStatusUpdateParam);
        log.debug("获取场站信息-入参{}，出参:{}",gunStatusUpdateParam,success);
        JsonResult<Boolean> result = JsonResult.ok(success,"获取枪状态成功");
        log.debug("获取场站信息-入参{}，出参:{}",gunStatusUpdateParam,result);
        return result;
    }
}
